Attribute VB_Name = "Module1"
Option Explicit
Global icdev As Integer
Global ihdevs(10) As Integer '存放多个设备句柄的数组
Global st As Integer


'comm function
Declare Function fw_init Lib "umf.dll" (ByVal port As Integer, ByVal baud As Long) As Integer
Declare Function fw_exit Lib "umf.dll" (ByVal icdev As Long) As Integer
Declare Function fw_request Lib "umf.dll" (ByVal icdev As Long, ByVal mode%, tagtype As Long) As Integer
Declare Function fw_anticoll Lib "umf.dll" (ByVal icdev As Long, ByVal bcnt%, snr As Long) As Integer
Declare Function fw_select Lib "umf.dll" (ByVal icdev As Long, ByVal snr As Long, size As Byte) As Integer
Declare Function fw_card Lib "umf.dll" (ByVal icdev As Long, ByVal mode%, snr As Long) As Integer
Declare Function fw_card_hex Lib "umf.dll" (ByVal icdev As Long, ByVal mode%, ByRef snrbuf As Byte) As Integer
Declare Function fw_card_str Lib "umf.dll" (ByVal icdev As Long, ByVal mode%, ByRef snrbuf As Byte) As Integer

Declare Function fw_load_key Lib "umf.dll" (ByVal icdev As Long, ByVal mode%, ByVal secnr%, ByRef nkey As Byte) As Integer
Declare Function fw_authentication Lib "umf.dll" (ByVal icdev As Long, ByVal mode%, ByVal scenr%) As Integer
Declare Function fw_read Lib "umf.dll" (ByVal icdev As Long, ByVal adr%, ByRef sdata As Byte) As Integer
Declare Function fw_write Lib "umf.dll" (ByVal icdev As Long, ByVal adr%, ByRef sdata As Byte) As Integer
Declare Function fw_changeb3 Lib "umf.dll" (ByVal adr As Long, ByVal secer As Integer, ByRef KeyA As Byte, ByRef Ctrlbytes As Byte, ByVal Bk As Integer, ByRef KeyB As Byte) As Integer



Declare Function fw_HL_initval Lib "umf.dll" (ByVal icdev As Long, ByVal mode As Integer, ByVal adr%, ByVal value As Long, ByRef snr As Long) As Integer
Declare Function fw_HL_increment Lib "umf.dll" (ByVal icdev As Long, ByVal mode As Integer, ByVal adr%, ByVal value As Long, ByVal snr As Long, value As Long, ByRef snr As Long) As Integer
Declare Function fw_HL_decrement Lib "umf.dll" (ByVal icdev As Long, ByVal mode As Integer, ByVal adr%, ByVal value As Long, ByVal snr As Long, value As Long, ByRef snr As Long) As Integer

'
Declare Function fw_initval Lib "umf.dll" (ByVal icdev As Long, ByVal adr%, ByVal value As Long) As Integer
Declare Function fw_readval Lib "umf.dll" (ByVal icdev As Long, ByVal adr%, value As Long) As Integer
Declare Function fw_increment Lib "umf.dll" (ByVal icdev As Long, ByVal adr%, ByVal value As Long) As Integer
Declare Function fw_decrement Lib "umf.dll" (ByVal icdev As Long, ByVal adr%, ByVal value As Long) As Integer
Declare Function fw_restore Lib "umf.dll" (ByVal icdev As Long, ByVal adr%) As Integer
Declare Function fw_transfer Lib "umf.dll" (ByVal icdev As Long, ByVal adr%) As Integer
Declare Function fw_halt Lib "umf.dll" (ByVal icdev As Long) As Integer
 

'device fuction
Declare Function fw_gettime Lib "umf.dll" (ByVal icdev As Long, ctime As Byte) As Integer
Declare Function fw_settime Lib "umf.dll" (ByVal icdev As Long, ctime As Byte) As Integer


Declare Function fw_reset Lib "umf.dll" (ByVal icdev As Long, ByVal msec%) As Integer
Declare Function fw_beep Lib "umf.dll" (ByVal icdev As Long, ByVal time1 As Integer) As Integer

'transfer function
Public Declare Sub hex_a Lib "umf.dll" (ByRef strHex As Byte, ByRef strBytes As Byte, ByVal hexLen%)        'strHex   [out]; strBytes [in]
Declare Function a_hex Lib "umf.dll" (ByRef strBytes As Byte, ByRef strHex As Byte, ByVal charLen%)  'strBytes [out]; strHex   [in]


'Ultralight function
Declare Function fw_request_ultralt Lib "umf.dll" (ByVal icdev As Long, ByVal mode%) As Integer
Declare Function fw_anticall_ultralt Lib "umf.dll" (ByVal icdev As Long, snr As Long) As Integer
Declare Function fw_select_ultralt Lib "umf.dll" (ByVal icdev As Long, ByVal snr As Long) As Integer
Declare Function fw_write_ultralt Lib "umf.dll" (ByVal icdev As Long, ByVal iblk%, ByRef sdata As Byte) As Integer
Declare Function fw_read_ultralt Lib "umf.dll" (ByVal icdev As Long, ByVal iblk%, ByRef sdata As Byte) As Integer




Sub quit()
    If icdev > 0 Then
       st = fw_exit(icdev)
       icdev = -1
    End If
End Sub


